package com.wanhai.itm.wditm143.vm;

import com.wanhai.vo.itm.ITM3012VO;
import com.wanhai.vo.itm.ITM4005VO;
import com.wanhai.vo.itm.ITM4007VO;
import com.wanhai.zkbase.core.WHL_BaseVM;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.zkoss.bind.annotation.AfterCompose;
import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.select.Selectors;
import org.zkoss.zul.Window;
import org.zkoss.zul.impl.InputElement;

/**
 *
 * @author Richard Shih
 */
public class WDITM143_VM extends WHL_BaseVM {

    private List<ITM4005VO> items = new ArrayList<ITM4005VO>();
    private List<ITM4007VO> fileItems = new ArrayList<ITM4007VO>();
    private String approverName;
    private String approverRank;
    private String comment;

    @Init(superclass = true)
    public void init() {
        ITM4005VO vo1 = new ITM4005VO();
        vo1.setPROJ_ID("9001");
        vo1.setPROJ_NO("2015MKT001");
        vo1.setPROJ_NM("DDS Tariff Copy 功能 及 tariff 架構調整");
        vo1.setEFF_DATE("20150101");
        vo1.setEXP_DATE("20150131");
        vo1.setPROJ_TYPE("Requirement");
        vo1.setPROJ_STATUS("Approved");

        ITM4005VO vo2 = new ITM4005VO();
        vo2.setPROJ_ID("9002");
        vo2.setPROJ_NO("2015MKT002");
        vo2.setPROJ_NM("WDBKG181:批核時無法同一船名航次搭配同一POL/POD統一批核");
        vo2.setEFF_DATE("20150101");
        vo2.setEXP_DATE("20150228");
        vo2.setPROJ_TYPE("Requirement");
        vo2.setPROJ_STATUS("Approved");

        ITM4005VO vo3 = new ITM4005VO();
        vo3.setPROJ_ID("9003");
        vo3.setPROJ_NO("TW201504W01");
        vo3.setPROJ_NM("TXGW TML server/storage EHHAMCEMENT");
        vo3.setEFF_DATE("20150415");
        vo3.setEXP_DATE("20150630");
        vo3.setPROJ_TYPE("Project");
        vo3.setPROJ_STATUS("Approved");

        ITM4005VO vo4 = new ITM4005VO();
        vo4.setPROJ_ID("9004");
        vo4.setPROJ_NO("");
        vo4.setPROJ_NM("日本提單作業流程Review");
        vo4.setEFF_DATE("20150501");
        vo4.setEXP_DATE("");
        vo4.setPROJ_TYPE("Project ");
        vo4.setPROJ_STATUS("Draft");

        items.add(vo1);
        items.add(vo2);
        items.add(vo3);
        items.add(vo4);

        ITM4007VO fileVO1 = new ITM4007VO();
        fileVO1.setSTORE_FILE_NAME("9001_01_WDCMS124.PDF");

        ITM4007VO fileVO2 = new ITM4007VO();
        fileVO2.setSTORE_FILE_NAME("9001_02_WDCMS608.DOC");

        fileItems.add(fileVO1);
        fileItems.add(fileVO2);

    }

    @AfterCompose(superclass = true)
    public void afterCompose() {
        try {
            Selectors.wireComponents(this.getRootView(), this, false);

        } catch (Exception e) {
            logger.warn(e.getMessage(), e);
        }
    }

    @Command("showComment")
    @NotifyChange({"approverName", "approverRank", "comment"})
    public void showComment(@BindingParam("approver") String approver, @BindingParam("rank") String rank, @BindingParam("comment") String comment) {
        this.approverName = approver;
        this.approverRank = rank;
        this.comment = comment;
        Window win = (Window) Executions.createComponents("wditm143_comment.zul", rootView, null);
        win.doModal();
    }

    @Command("save")
    public void onSave() {
//        Clients.showNotification(String.valueOf(saveProgress.getValue()));
    }

    @Command("preInsert")
    public void preInsert() {
        Window win = null;
        win = (Window) Executions.createComponents("wditm143_s.zul", rootView, null);
        win.doModal();
    }

    public List<ITM4005VO> getItems() {
        return items;
    }

    public void setItems(List<ITM4005VO> items) {
        this.items = items;
    }

    public List<ITM4007VO> getFileItems() {
        return fileItems;
    }

    public void setFileItems(List<ITM4007VO> fileItems) {
        this.fileItems = fileItems;
    }

    public String getApproverName() {
        return approverName;
    }

    public void setApproverName(String approverName) {
        this.approverName = approverName;
    }

    public String getApproverRank() {
        return approverRank;
    }

    public void setApproverRank(String approverRank) {
        this.approverRank = approverRank;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }
}
